package com.example.projectjava.service;


import com.example.projectjava.dao.AdminDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AdminService {
    @Autowired
    AdminDao adminDao;//spring会自动将adminDao注入到此类为(自动为该属性赋值)

    public int adminLogin(String adminname, String pwd){
        List<Map<String, Object>> res =  adminDao.queryAdminByName(adminname);
        if(res.size()==0){
            throw  new RuntimeException("非管理员");
        }
        String right_pwd = res.get(0).get("pwd").toString();
        if (!right_pwd.equals(pwd)){
            throw  new RuntimeException("密码错误");
        }
        return 1;
    }
}
